<template>
  <div id="capital" class="capital-container">
    <div class="head">
      <div class="top">
        <el-form ref="form" :model="form" label-width="100px">
          <div class="item">
            <el-form-item class="date" label="提现日期:">
              <el-date-picker
                v-model="form.date"
                type="date"
                placeholder="年/月/日">
              </el-date-picker>
              <span class="dash">~</span>
              <el-date-picker
                v-model="form.finaldate"
                type="date"
                placeholder="年/月/日">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button @click="yesterday">昨天</el-button>
              <el-button @click="week">近一周</el-button>
              <el-button @click="month">近一月</el-button>
            </el-form-item>
          </div>
          <div class="item">
            <el-form-item label="银行账户:">
              <el-select v-model="selectAccount" placeholder="" @click="getAccount(item)">
                <el-option
                  v-for="item in account"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="提现人:">
              <el-select v-model="selectPeople" placeholder="" @click="getPeople(item)">
                <el-option
                  v-for="item in teacher"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="提现状态:">
              <el-select v-model="selectState" placeholder="" @click="getState(item)">
                <el-option
                  v-for="item in state"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <div class="btn">
              <el-button type="primary">查询</el-button>
              <el-button type="warning" @click="reset">重置</el-button>
            </div>
          </div>
        </el-form>
      </div>
      <div class="foot" @click="getCash">
        <el-button type="primary">提现</el-button>
      </div>
    </div>
    <div class="main">
      <div class="maintop">
        <p>总计:</p>
        <span>250.00元</span>
      </div>
      <div class="body">
        <el-table
          :data="tableData"
          border
          style="width: 98%"
          :header-cell-style="{background:'#f5f4f4'}">
          <el-table-column
            prop="date"
            label="提现日期"
            width="250">
          </el-table-column>
          <el-table-column
            prop="money"
            label="金额"
            width="222">
          </el-table-column>
          <el-table-column
            prop="account"
            label="银行账户"
            width="260">
          </el-table-column>
          <el-table-column
            prop="people"
            label="提现人"
            width="220">
          </el-table-column>
          <el-table-column
            prop="state"
            label="提现状态"
            width="220">
          </el-table-column>
          <el-table-column
            prop="remarks"
            label="备注"
            width="240">
          </el-table-column>
          <el-table-column
            label="操作"
            width="220">
            <template slot-scope="scope">
              <el-button size="small" style="color:#f704d7">打印</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            :current-page.sync="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="100"
            layout="prev, pager, next, sizes, jumper"
            :total="1000">
          </el-pagination>
        </div>
      </div>
    </div>
    <el-dialog
      title="提现"
      :visible.sync="show"
      width="70%"
      class="cash"
      :before-close="handleClose">
      <el-form ref="form" :model="cash" label-width="100px">
        <el-form-item label="选择银行卡:">
          <div class="term" :class="{active:item.tog}" @click="getTog(index)" v-for="(item,index) in bankCard" :key="index">
            <p>
              <span>开户行:</span>
              <span>{{item.openingValue}}</span>
            </p>
            <p>
              <span>户名:</span>
              <span>{{item.accountName}}</span>
            </p>
            <p>
              <span>账户:</span>
              <span>{{item.accountNumber}}</span>
            </p>
          </div>
        </el-form-item>
        <el-form-item label="提现金额:">
          <el-input type="text" v-model="cash.money" placeholder=""></el-input>￥
        </el-form-item>
        <el-form-item label="提现备注:">
          <el-input type="textarea" v-model="cash.remarks"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="close">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getAccount, getCapitaldata, getBankcarddata } from "@/api/bank";
import { GetTeacher } from "@/api/class";
import { lchown } from 'fs';
  export default {
    name:"capital",
    data() {
      return {
        selectAccount:"",
        selectPeople:"",
        selectState:"",
        currentPage:1,
        show:false,
        form:{
          date:'',
          finaldate:''
        },
        account:[],
        teacher:[],
        state:[
          {value:"选项1",label:"成功"},
          {value:"选项2",label:"失败"}
        ],
        tableData:[],
        bankCard:[],
        cash:{
          money:'',
          remarks:''
        }
      }
    },
    mounted(){
      this.init();
      this.teachers();
      this.bill();
      this.bank();
    },
    methods: {
      init() {
        getAccount().then( res => {
          if(res.code === 200) {
            this.account = res.data;
          }
        })
      },
      teachers() {
        GetTeacher().then( res => {
          if(res.code === 200) {
            this.teacher = res.data;
          }
        })
      },
      bill() {
        getCapitaldata().then( res => {
          if(res.code === 200) {
            this.tableData = res.data;
          }
        })
      },
      bank() {
        getBankcarddata().then( res => {
          if(res.code === 200) {
            this.bankCard = res.data;
          }
        })
      },
      yesterday() {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24);
        this.form.date = date;
        this.form.finaldate = new Date();
      },
      week() {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
        this.form.date = date;
        this.form.finaldate = new Date();
      },
      month() {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24 * 30);
        this.form.date = date;
        this.form.finaldate = new Date();
      },
      reset() {
        this.form.date ="",
        this.form.finaldate ="",
        this.selectAccount ="",
        this.selectPeople ="",
        this.selectState =""
      },
      getCash() {
        this.show = true;
      },
      close() {
        this.show = false;
      },
      getTog(index) {
        this.bankCard[index].tog = !this.bankCard[index].tog;
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.capital-container {
  width: 98%;
  height: 865px;
  margin-top: 20px;
  margin-left: 20px;
  background:#fff;
  position: relative;
}
.head{
  width: 100%;
  height: 200px;
  border-bottom: 1px solid #ccc;
  .top{
    width: 94%;
    height: 50px;
    margin: 0 auto;
    padding-top: 20px;
    /deep/ .el-form-item{
      display: inline-block;
      width: 24%;
    }
    .date{
      width: 36%;
    }
    /deep/ .el-form-item__label{
      width: 101px !important;
    }
    /deep/ .el-input{
      width: auto;
    }
    .btn{
      display: inline-block;
      width: 20%;
    }
  }
  .foot{
    margin-left: 55px;
    margin-top: 90px;
    width: 70px;
  }
}
.main{
  width:100%;
  height:600px;
  .body{
    /deep/ .cell{
      text-align: center;
    }
    /deep/ .el-button{
      border: none;
      color: #00f;
      padding: 0;
    }
    .block{
      float: right;
      margin-top: 20px;
      margin-right: 88px;
      /deep/ .el-pagination button{
        border: 1px solid #ccc;
        border-radius: 5px;
        margin-right: 10px;
      }
      /deep/ .el-pager li{
        border: 1px solid #ccc;
        border-radius: 5px;
        margin-right: 10px;
      }
      /deep/ .el-pager li.active{
        background: #409EFF;
        color: #fff;
        border: none;
      }
    }
  }
}
.maintop{
  width:95%;
  height:50px;
  margin:0 auto;
  margin-top: 10px;
  p{
    display: inline-block;
  }
  span{
    color:#339900;
  }
}
.cash{
  /deep/ .el-dialog{
    .term{
      width: 240px;
      height: 100px;
      border: 1px solid #000;
      padding-left: 10px;
      float: left;
      margin-right: 40px;
      p{
        margin: 0;
        padding: 0;
        height: 30px;
        span:first-child{
          display: inline-block;
          width: 50px;
          text-align: right;
        }
      }
    }
    .active{
      border: 1px solid #27bb27;
    }
    .el-form-item__content{
      display: inline-block;
      margin-left: 0 !important;
      .el-input{
        width: 85%;
        margin-right: 10px;
      }
      .el-textarea__inner{
        width: 250px;
        height: 160px;
        outline: none;
      }
    }
  }
}
</style>